<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId'.$cfgPack])
   || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['index'][$_SESSION['s_userType'.$cfgPack]]) 
        && $cfgFileNames['index'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{	
	$previousDate            = date("Y-m-d",strtotime("previous day"));
	$nextDate                = date("Y-m-d",strtotime("next day"));
	$currentDate             = date("Y-m-d");
  $UserName                = "";
  $companyName             = "";
  $popup                   = 0;
  $dailyReportDetailArray  = array();
  $dailyReportCount        = 0;
  $nextFollowUp            = 0;
  $selectdailyReportEntry  = "SELECT dailyreportmaster.dailyReportMasterId,user.userId,user.userName,DATE_FORMAT(dailyreportmaster.reportDate,'%d-%m-%Y') AS reportDate,
                                     DATE_FORMAT(dailyreportmaster.createDate,'%d-%m-%Y') AS createDate,dailyreportdetail.dailyReportMasterId,
                                     party.partyId,party.companyName,dailyreportdetail.outCome,dailyreportdetail.remarks,dailyreportdetail.dailyReportDetaileId,
                                     DATE_FORMAT(dailyreportdetail.nextFollowUp,'%d-%m-%Y') AS nextFollowUp,typeofconclusion.typeOfConclusionId,typeofconclusion.typeOfConclusion
				  						          FROM dailyreportmaster
				  						          JOIN dailyreportdetail
					 						          JOIN user   
						 					          JOIN party
											          JOIN typeofconclusion 
											         WHERE user.userId      = dailyreportmaster.userId
											           AND dailyreportmaster.dailyReportMasterId    = dailyreportdetail.dailyReportMasterId 
											           AND party.partyId    = dailyreportdetail.partyId 
											           AND typeofconclusion.typeOfConclusionId = dailyreportdetail.typeOfConclusionId
											           AND dailyreportmaster.userId = ".$_SESSION['s_activeUserId'.$cfgPack]."
                                 AND dailyreportdetail.nextFollowUp <= '".$currentDate."'
                                 AND dailyreportdetail.status = 'A'
                                 AND dailyreportdetail.typeOfConclusionId = '1'";
    $selectdailyReportEntryResult = mysql_query($selectdailyReportEntry);
    while($dailyReportRow = mysql_fetch_array($selectdailyReportEntryResult))
	  {
	  	$popup     = 1;
		  $nextFollowUp = $dailyReportRow['nextFollowUp'];
		  $companyName  = $dailyReportRow['companyName'];
		  $dailyReportDetailArray[$dailyReportCount]['dailyReportDetaileId']     = $dailyReportRow['dailyReportDetaileId'];
		  $dailyReportDetailArray[$dailyReportCount]['nextFollowUp']             = $dailyReportRow['nextFollowUp'];
		  $dailyReportDetailArray[$dailyReportCount]['companyName']              = $dailyReportRow['companyName'];
		  //$dailyReportDetailArray[$dailyReportCount]['typeOfConclusion']     = $dailyReportRow['typeOfConclusion'];
		  $dailyReportCount++;
	  }  
	include("./bottom.php");
	$smarty->assign("nextFollowUp",$nextFollowUp);
	$smarty->assign("dailyReportDetailArray",$dailyReportDetailArray);
	$smarty->assign("companyName",$companyName);
	$smarty->assign("popup",$popup);
	$smarty->display("index.tpl");
}
?>